package com.rd.student.ruanjian.class4.zhouzihe.day0728;

import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.util.Random;
import java.util.Scanner;

public class Randomizer implements Serializable {
    public static void main(String[] args) {
     String str ="郑成祥、王博、孙文卓、郑睿娴、王高博、李春泉、张睿、王星凯、柏云耀、高艺铭、周子贺、杜航、高晨曦、张思韬、孙昊、方周、郭佳宝、姜万里、李宏鸣、薛志鑫、王海鑫、夏银银、吴俊豪、王向阳、徐铭泽、张世煊、才雨鑫、孙国伟、秦嘉林、王岩博、石睿、杜雨坤、黄奕鸣、金洪宇、李鑫、王宇芳、苏岩";
     String [] arr =str.split(",");
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i <arr.length; i++) {
            System.out.println("存储第"+i+"个姓名：");
            arr[i] = sc.next();
        }
        for(int i = 0; i < arr.length; i++) {
            String name = arr[i];
            //打印姓名
            System.out.println("第" + i + "个学生姓名为:" + name);
        }

        //根据数组长度，获取随机索引
        int index = new Random().nextInt(arr.length);
        String name = arr[index];
        System.out.println("被点到的人为："+name);

        String projectPath = System.getProperty("user.dir");
        File file = new File(projectPath+"\\"+"all.txt");
        try {
            file.createNewFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
        }



